[gimp] Add basic infrastructure for trees of viewables



commit 1e5da3939bc27ebd6f2c7a960fd2ce3648e91bfd
Author: Michael Natterer <mitch gimp org>
Date:   Sat Aug 1 19:04:33 2009 +0200

    Add basic infrastructure for trees of viewables
    
    - add member "GimpViewable *parent" and accessors to get/set it
      (no property or signals yet)
    - add virtual function ::get_children() which is supposed to return
      a GimpContainer of the viewable's children

 app/core/gimpviewable.c |   35 +++++++
 app/core/gimpviewable.h |  225 ++++++++++++++++++++++++----------------------
 2 files changed, 152 insertions(+), 108 deletions(-)
---
diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c
index 4060d17..858c1e2 100644
--- a/app/core/gimpviewable.c
+++ b/app/core/gimpviewable.c
@@ -89,6 +89,8 @@ static gboolean gimp_viewable_real_get_popup_size    (GimpViewable  *viewable,
                                                       gint          *popup_height);
 static gchar * gimp_viewable_real_get_description    (GimpViewable  *viewable,
                                                       gchar        **tooltip);
+static GimpContainer * gimp_viewable_real_get_children (GimpViewable *viewable);
+
 static gboolean gimp_viewable_serialize_property     (GimpConfig    *config,
                                                       guint          property_id,
                                                       const GValue  *value,
@@ -154,6 +156,7 @@ gimp_viewable_class_init (GimpViewableClass *klass)
   klass->get_pixbuf              = NULL;
   klass->get_new_pixbuf          = gimp_viewable_real_get_new_pixbuf;
   klass->get_description         = gimp_viewable_real_get_description;
+  klass->get_children            = gimp_viewable_real_get_children;
 
   GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_STOCK_ID, "stock-id",
                                    NULL, NULL,
@@ -374,6 +377,12 @@ gimp_viewable_real_get_description (GimpViewable  *viewable,
   return g_strdup (gimp_object_get_name (GIMP_OBJECT (viewable)));
 }
 
+static GimpContainer *
+gimp_viewable_real_get_children (GimpViewable *viewable)
+{
+  return NULL;
+}
+
 static gboolean
 gimp_viewable_serialize_property (GimpConfig       *config,
                                   guint             property_id,
@@ -1092,3 +1101,29 @@ gimp_viewable_preview_is_frozen (GimpViewable *viewable)
 
   return viewable->freeze_count != 0;
 }
+
+GimpViewable *
+gimp_viewable_get_parent (GimpViewable *viewable)
+{
+  g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
+
+  return viewable->parent;
+}
+
+void
+gimp_viewable_set_parent (GimpViewable *viewable,
+                          GimpViewable *parent)
+{
+  g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
+  g_return_if_fail (parent == NULL || GIMP_IS_VIEWABLE (parent));
+
+  viewable->parent = parent;
+}
+
+GimpContainer *
+gimp_viewable_get_children (GimpViewable *viewable)
+{
+  g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
+
+  return GIMP_VIEWABLE_GET_CLASS (viewable)->get_children (viewable);
+}
diff --git a/app/core/gimpviewable.h b/app/core/gimpviewable.h
index 133b673..d472256 100644
--- a/app/core/gimpviewable.h
+++ b/app/core/gimpviewable.h
@@ -47,11 +47,12 @@ typedef struct _GimpViewableClass GimpViewableClass;
 
 struct _GimpViewable
 {
-  GimpObject  parent_instance;
+  GimpObject    parent_instance;
 
   /*<  private  >*/
-  gchar      *stock_id;
-  gint        freeze_count;
+  gchar        *stock_id;
+  gint          freeze_count;
+  GimpViewable *parent;
 };
 
 struct _GimpViewableClass
@@ -62,116 +63,124 @@ struct _GimpViewableClass
   const gchar     *name_changed_signal;
 
   /*  signals  */
-  void        (* invalidate_preview) (GimpViewable  *viewable);
-  void        (* size_changed)       (GimpViewable  *viewable);
+  void            (* invalidate_preview) (GimpViewable  *viewable);
+  void            (* size_changed)       (GimpViewable  *viewable);
 
   /*  virtual functions  */
-  gboolean    (* get_size)           (GimpViewable  *viewable,
-                                      gint          *width,
-                                      gint          *height);
-  void        (* get_preview_size)   (GimpViewable  *viewable,
-                                      gint           size,
-                                      gboolean       is_popup,
-                                      gboolean       dot_for_dot,
-                                      gint          *width,
-                                      gint          *height);
-  gboolean    (* get_popup_size)     (GimpViewable  *viewable,
-                                      gint           width,
-                                      gint           height,
-                                      gboolean       dot_for_dot,
-                                      gint          *popup_width,
-                                      gint          *popup_height);
-  TempBuf   * (* get_preview)        (GimpViewable  *viewable,
-                                      GimpContext   *context,
-                                      gint           width,
-                                      gint           height);
-  TempBuf   * (* get_new_preview)    (GimpViewable  *viewable,
-                                      GimpContext   *context,
-                                      gint           width,
-                                      gint           height);
-  GdkPixbuf * (* get_pixbuf)         (GimpViewable  *viewable,
-                                      GimpContext   *context,
-                                      gint           width,
-                                      gint           height);
-  GdkPixbuf * (* get_new_pixbuf)     (GimpViewable  *viewable,
-                                      GimpContext   *context,
-                                      gint           width,
-                                      gint           height);
-  gchar     * (* get_description)    (GimpViewable  *viewable,
-                                      gchar        **tooltip);
+  gboolean        (* get_size)           (GimpViewable  *viewable,
+                                          gint          *width,
+                                          gint          *height);
+  void            (* get_preview_size)   (GimpViewable  *viewable,
+                                          gint           size,
+                                          gboolean       is_popup,
+                                          gboolean       dot_for_dot,
+                                          gint          *width,
+                                          gint          *height);
+  gboolean        (* get_popup_size)     (GimpViewable  *viewable,
+                                          gint           width,
+                                          gint           height,
+                                          gboolean       dot_for_dot,
+                                          gint          *popup_width,
+                                          gint          *popup_height);
+  TempBuf       * (* get_preview)        (GimpViewable  *viewable,
+                                          GimpContext   *context,
+                                          gint           width,
+                                          gint           height);
+  TempBuf       * (* get_new_preview)    (GimpViewable  *viewable,
+                                          GimpContext   *context,
+                                          gint           width,
+                                          gint           height);
+  GdkPixbuf     * (* get_pixbuf)         (GimpViewable  *viewable,
+                                          GimpContext   *context,
+                                          gint           width,
+                                          gint           height);
+  GdkPixbuf     * (* get_new_pixbuf)     (GimpViewable  *viewable,
+                                          GimpContext   *context,
+                                          gint           width,
+                                          gint           height);
+  gchar         * (* get_description)    (GimpViewable  *viewable,
+                                          gchar        **tooltip);
+
+  GimpContainer * (* get_children)       (GimpViewable  *viewable);
 };
 
 
-GType       gimp_viewable_get_type           (void) G_GNUC_CONST;
-
-void        gimp_viewable_invalidate_preview (GimpViewable  *viewable);
-void        gimp_viewable_size_changed       (GimpViewable  *viewable);
-
-void        gimp_viewable_calc_preview_size  (gint           aspect_width,
-                                              gint           aspect_height,
-                                              gint           width,
-                                              gint           height,
-                                              gboolean       dot_for_dot,
-                                              gdouble        xresolution,
-                                              gdouble        yresolution,
-                                              gint          *return_width,
-                                              gint          *return_height,
-                                              gboolean      *scaling_up);
-
-gboolean    gimp_viewable_get_size           (GimpViewable  *viewable,
-                                              gint          *width,
-                                              gint          *height);
-void        gimp_viewable_get_preview_size   (GimpViewable  *viewable,
-                                              gint           size,
-                                              gboolean       popup,
-                                              gboolean       dot_for_dot,
-                                              gint          *width,
-                                              gint          *height);
-gboolean    gimp_viewable_get_popup_size     (GimpViewable  *viewable,
-                                              gint           width,
-                                              gint           height,
-                                              gboolean       dot_for_dot,
-                                              gint          *popup_width,
-                                              gint          *popup_height);
-
-TempBuf   * gimp_viewable_get_preview        (GimpViewable  *viewable,
-                                              GimpContext   *context,
-                                              gint           width,
-                                              gint           height);
-TempBuf   * gimp_viewable_get_new_preview    (GimpViewable  *viewable,
-                                              GimpContext   *context,
-                                              gint           width,
-                                              gint           height);
-
-TempBuf   * gimp_viewable_get_dummy_preview  (GimpViewable  *viewable,
-                                              gint           width,
-                                              gint           height,
-                                              gint           bpp);
-
-GdkPixbuf * gimp_viewable_get_pixbuf         (GimpViewable  *viewable,
-                                              GimpContext   *context,
-                                              gint           width,
-                                              gint           height);
-GdkPixbuf * gimp_viewable_get_new_pixbuf     (GimpViewable  *viewable,
-                                              GimpContext   *context,
-                                              gint           width,
-                                              gint           height);
-
-GdkPixbuf * gimp_viewable_get_dummy_pixbuf   (GimpViewable  *viewable,
-                                              gint           width,
-                                              gint           height,
-                                              gint           bpp);
-
-gchar     * gimp_viewable_get_description    (GimpViewable  *viewable,
-                                              gchar        **tooltip);
-
-const gchar * gimp_viewable_get_stock_id     (GimpViewable  *viewable);
-void          gimp_viewable_set_stock_id     (GimpViewable  *viewable,
-                                              const gchar   *stock_id);
-
-void        gimp_viewable_preview_freeze     (GimpViewable  *viewable);
-void        gimp_viewable_preview_thaw       (GimpViewable  *viewable);
-gboolean    gimp_viewable_preview_is_frozen  (GimpViewable  *viewable);
+GType           gimp_viewable_get_type           (void) G_GNUC_CONST;
+
+void            gimp_viewable_invalidate_preview (GimpViewable  *viewable);
+void            gimp_viewable_size_changed       (GimpViewable  *viewable);
+
+void            gimp_viewable_calc_preview_size  (gint           aspect_width,
+                                                  gint           aspect_height,
+                                                  gint           width,
+                                                  gint           height,
+                                                  gboolean       dot_for_dot,
+                                                  gdouble        xresolution,
+                                                  gdouble        yresolution,
+                                                  gint          *return_width,
+                                                  gint          *return_height,
+                                                  gboolean      *scaling_up);
+
+gboolean        gimp_viewable_get_size           (GimpViewable  *viewable,
+                                                  gint          *width,
+                                                  gint          *height);
+void            gimp_viewable_get_preview_size   (GimpViewable  *viewable,
+                                                  gint           size,
+                                                  gboolean       popup,
+                                                  gboolean       dot_for_dot,
+                                                  gint          *width,
+                                                  gint          *height);
+gboolean        gimp_viewable_get_popup_size     (GimpViewable  *viewable,
+                                                  gint           width,
+                                                  gint           height,
+                                                  gboolean       dot_for_dot,
+                                                  gint          *popup_width,
+                                                  gint          *popup_height);
+
+TempBuf       * gimp_viewable_get_preview        (GimpViewable  *viewable,
+                                                  GimpContext   *context,
+                                                  gint           width,
+                                                  gint           height);
+TempBuf       * gimp_viewable_get_new_preview    (GimpViewable  *viewable,
+                                                  GimpContext   *context,
+                                                  gint           width,
+                                                  gint           height);
+
+TempBuf       * gimp_viewable_get_dummy_preview  (GimpViewable  *viewable,
+                                                  gint           width,
+                                                  gint           height,
+                                                  gint           bpp);
+
+GdkPixbuf     * gimp_viewable_get_pixbuf         (GimpViewable  *viewable,
+                                                  GimpContext   *context,
+                                                  gint           width,
+                                                  gint           height);
+GdkPixbuf     * gimp_viewable_get_new_pixbuf     (GimpViewable  *viewable,
+                                                  GimpContext   *context,
+                                                  gint           width,
+                                                  gint           height);
+
+GdkPixbuf     * gimp_viewable_get_dummy_pixbuf   (GimpViewable  *viewable,
+                                                  gint           width,
+                                                  gint           height,
+                                                  gint           bpp);
+
+gchar         * gimp_viewable_get_description    (GimpViewable  *viewable,
+                                                  gchar        **tooltip);
+
+const gchar   * gimp_viewable_get_stock_id       (GimpViewable  *viewable);
+void            gimp_viewable_set_stock_id       (GimpViewable  *viewable,
+                                                  const gchar   *stock_id);
+
+void            gimp_viewable_preview_freeze     (GimpViewable  *viewable);
+void            gimp_viewable_preview_thaw       (GimpViewable  *viewable);
+gboolean        gimp_viewable_preview_is_frozen  (GimpViewable  *viewable);
+
+GimpViewable  * gimp_viewable_get_parent         (GimpViewable  *viewable);
+void            gimp_viewable_set_parent         (GimpViewable  *viewable,
+                                                  GimpViewable  *parent);
+
+GimpContainer * gimp_viewable_get_children       (GimpViewable  *viewable);
 
 
 #endif  /* __GIMP_VIEWABLE_H__ */



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