[kdbus] KDBUS_ITEM_PAYLOAD_OFF items are (once again) relative to msg header
[platform/upstream/glib.git] / gio / gfileicon.c
index 26f2825..2eaec7b 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Author: Alexander Larsson <alexl@redhat.com>
  */
@@ -120,7 +118,8 @@ g_file_icon_finalize (GObject *object)
 
   icon = G_FILE_ICON (object);
 
-  g_object_unref (icon->file);
+  if (icon->file)
+    g_object_unref (icon->file);
 
   G_OBJECT_CLASS (g_file_icon_parent_class)->finalize (object);
 }
@@ -256,6 +255,14 @@ g_file_icon_from_tokens (gchar  **tokens,
   return icon;
 }
 
+static GVariant *
+g_file_icon_serialize (GIcon *icon)
+{
+  GFileIcon *file_icon = G_FILE_ICON (icon);
+
+  return g_variant_new ("(sv)", "file", g_variant_new_take_string (g_file_get_uri (file_icon->file)));
+}
+
 static void
 g_file_icon_icon_iface_init (GIconIface *iface)
 {
@@ -263,6 +270,7 @@ g_file_icon_icon_iface_init (GIconIface *iface)
   iface->equal = g_file_icon_equal;
   iface->to_tokens = g_file_icon_to_tokens;
   iface->from_tokens = g_file_icon_from_tokens;
+  iface->serialize = g_file_icon_serialize;
 }
 
 
@@ -279,6 +287,9 @@ g_file_icon_load (GLoadableIcon  *icon,
   stream = g_file_read (file_icon->file,
                        cancellable,
                        error);
+
+  if (stream && type)
+    *type = NULL;
   
   return G_INPUT_STREAM (stream);
 }