gdkcursor.c 2.07 KB
Newer Older
Havoc Pennington's avatar
Havoc Pennington committed
1 2 3 4
/* GDK - The GIMP Drawing Kit
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Havoc Pennington's avatar
Havoc Pennington committed
6 7 8 9 10 11
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
Havoc Pennington's avatar
Havoc Pennington committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
Havoc Pennington's avatar
Havoc Pennington committed
15 16 17 18 19 20
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
Havoc Pennington's avatar
Havoc Pennington committed
22 23 24 25 26 27
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

#include "gdkcursor.h"
28
#include "gdkinternals.h"
Havoc Pennington's avatar
Havoc Pennington committed
29

30 31 32 33 34 35 36 37
GType
gdk_cursor_get_type (void)
{
  static GType our_type = 0;
  
  if (our_type == 0)
    our_type = g_boxed_type_register_static ("GdkCursor",
					     (GBoxedCopyFunc)gdk_cursor_ref,
38
					     (GBoxedFreeFunc)gdk_cursor_unref);
39 40 41
  return our_type;
}

Havoc Pennington's avatar
Havoc Pennington committed
42 43 44 45 46 47 48 49
/**
 * gdk_cursor_ref:
 * @cursor: a #GdkCursor
 * 
 * Adds a reference to @cursor.
 * 
 * Return value: Same @cursor that was passed in
 **/
Havoc Pennington's avatar
Havoc Pennington committed
50 51 52
GdkCursor*
gdk_cursor_ref (GdkCursor *cursor)
{
Tim Janik's avatar
Tim Janik committed
53 54 55 56
  g_return_val_if_fail (cursor != NULL, NULL);
  g_return_val_if_fail (cursor->ref_count > 0, NULL);

  cursor->ref_count += 1;
Havoc Pennington's avatar
Havoc Pennington committed
57 58 59 60

  return cursor;
}

Havoc Pennington's avatar
Havoc Pennington committed
61 62 63 64 65 66 67 68
/**
 * gdk_cursor_unref:
 * @cursor: a #GdkCursor
 *
 * Removes a reference from @cursor, deallocating the cursor
 * if no references remain.
 * 
 **/
Havoc Pennington's avatar
Havoc Pennington committed
69 70 71 72
void
gdk_cursor_unref (GdkCursor *cursor)
{
  g_return_if_fail (cursor != NULL);
Tim Janik's avatar
Tim Janik committed
73
  g_return_if_fail (cursor->ref_count > 0);
Havoc Pennington's avatar
Havoc Pennington committed
74

Tim Janik's avatar
Tim Janik committed
75
  cursor->ref_count -= 1;
Havoc Pennington's avatar
Havoc Pennington committed
76

Tim Janik's avatar
Tim Janik committed
77 78
  if (cursor->ref_count == 0)
    _gdk_cursor_destroy (cursor);
Havoc Pennington's avatar
Havoc Pennington committed
79 80
}