[gnome-flashback] desktop: pass GfIconView to GfIcon



commit d7a504f67be8647ad2c4aa7e390d719c94828a36
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Nov 13 21:54:48 2019 +0200

    desktop: pass GfIconView to GfIcon

 gnome-flashback/libdesktop/gf-dummy-icon.c |  3 ++-
 gnome-flashback/libdesktop/gf-dummy-icon.h |  2 +-
 gnome-flashback/libdesktop/gf-icon-view.c  |  4 ++--
 gnome-flashback/libdesktop/gf-icon.c       | 23 +++++++++++++++++++++--
 gnome-flashback/libdesktop/gf-icon.h       |  5 +++--
 5 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/gnome-flashback/libdesktop/gf-dummy-icon.c b/gnome-flashback/libdesktop/gf-dummy-icon.c
index 8f6f6a7..a4c70b0 100644
--- a/gnome-flashback/libdesktop/gf-dummy-icon.c
+++ b/gnome-flashback/libdesktop/gf-dummy-icon.c
@@ -150,7 +150,7 @@ gf_dummy_icon_init (GfDummyIcon *self)
 }
 
 GtkWidget *
-gf_dummy_icon_new (void)
+gf_dummy_icon_new (GfIconView *icon_view)
 {
   GFile *file;
   GFileInfo *info;
@@ -173,6 +173,7 @@ gf_dummy_icon_new (void)
   g_file_info_set_display_name (info, name);
 
   widget = g_object_new (GF_TYPE_DUMMY_ICON,
+                         "icon-view", icon_view,
                          "file", file,
                          "info", info,
                          NULL);
diff --git a/gnome-flashback/libdesktop/gf-dummy-icon.h b/gnome-flashback/libdesktop/gf-dummy-icon.h
index 95fa3ab..b9e203b 100644
--- a/gnome-flashback/libdesktop/gf-dummy-icon.h
+++ b/gnome-flashback/libdesktop/gf-dummy-icon.h
@@ -25,7 +25,7 @@ G_BEGIN_DECLS
 #define GF_TYPE_DUMMY_ICON (gf_dummy_icon_get_type ())
 G_DECLARE_FINAL_TYPE (GfDummyIcon, gf_dummy_icon, GF, DUMMY_ICON, GfIcon)
 
-GtkWidget *gf_dummy_icon_new        (void);
+GtkWidget *gf_dummy_icon_new        (GfIconView  *icon_view);
 
 int        gf_dummy_icon_get_width  (GfDummyIcon *self);
 
diff --git a/gnome-flashback/libdesktop/gf-icon-view.c b/gnome-flashback/libdesktop/gf-icon-view.c
index 4394a1c..88197b0 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.c
+++ b/gnome-flashback/libdesktop/gf-icon-view.c
@@ -345,7 +345,7 @@ create_icon_info (GfIconView *self,
 {
   GtkWidget *icon;
 
-  icon = gf_icon_new (file, info);
+  icon = gf_icon_new (self, file, info);
 
   g_signal_connect (icon, "selected",
                     G_CALLBACK (icon_selected_cb),
@@ -1233,7 +1233,7 @@ create_dummy_icon (GfIconView *self)
 {
   GtkWidget *widget;
 
-  widget = gf_dummy_icon_new ();
+  widget = gf_dummy_icon_new (self);
 
   g_settings_bind (self->settings, "icon-size",
                    widget, "icon-size",
diff --git a/gnome-flashback/libdesktop/gf-icon.c b/gnome-flashback/libdesktop/gf-icon.c
index 37899ca..e583ffb 100644
--- a/gnome-flashback/libdesktop/gf-icon.c
+++ b/gnome-flashback/libdesktop/gf-icon.c
@@ -28,6 +28,7 @@ typedef struct
 {
   GtkGesture *multi_press;
 
+  GfIconView *icon_view;
   GFile      *file;
   GFileInfo  *info;
 
@@ -46,6 +47,7 @@ enum
 {
   PROP_0,
 
+  PROP_ICON_VIEW,
   PROP_FILE,
   PROP_INFO,
 
@@ -356,6 +358,11 @@ gf_icon_set_property (GObject      *object,
 
   switch (property_id)
     {
+      case PROP_ICON_VIEW:
+        g_assert (priv->icon_view == NULL);
+        priv->icon_view = g_value_get_object (value);
+        break;
+
       case PROP_FILE:
         g_assert (priv->file == NULL);
         priv->file = g_value_dup_object (value);
@@ -403,6 +410,16 @@ gf_icon_get_preferred_width (GtkWidget *widget,
 static void
 install_properties (GObjectClass *object_class)
 {
+  icon_properties[PROP_ICON_VIEW] =
+    g_param_spec_object ("icon-view",
+                         "icon-view",
+                         "icon-view",
+                         GF_TYPE_ICON_VIEW,
+                         G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_WRITABLE |
+                         G_PARAM_EXPLICIT_NOTIFY |
+                         G_PARAM_STATIC_STRINGS);
+
   icon_properties[PROP_FILE] =
     g_param_spec_object ("file",
                          "file",
@@ -532,10 +549,12 @@ gf_icon_init (GfIcon *self)
 }
 
 GtkWidget *
-gf_icon_new (GFile     *file,
-             GFileInfo *info)
+gf_icon_new (GfIconView *icon_view,
+             GFile      *file,
+             GFileInfo  *info)
 {
   return g_object_new (GF_TYPE_ICON,
+                       "icon-view", icon_view,
                        "file", file,
                        "info", info,
                        NULL);
diff --git a/gnome-flashback/libdesktop/gf-icon.h b/gnome-flashback/libdesktop/gf-icon.h
index fdf9e76..9ac0d92 100644
--- a/gnome-flashback/libdesktop/gf-icon.h
+++ b/gnome-flashback/libdesktop/gf-icon.h
@@ -18,7 +18,7 @@
 #ifndef GF_ICON_H
 #define GF_ICON_H
 
-#include <gtk/gtk.h>
+#include "gf-icon-view.h"
 
 G_BEGIN_DECLS
 
@@ -38,7 +38,8 @@ struct _GfIconClass
   GtkButtonClass parent_class;
 };
 
-GtkWidget  *gf_icon_new          (GFile               *file,
+GtkWidget  *gf_icon_new          (GfIconView          *icon_view,
+                                  GFile               *file,
                                   GFileInfo           *info);
 
 GFile      *gf_icon_get_file     (GfIcon              *self);


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