[gtk+/gtk-3-0] dnd: Use G_N_ELEMENTS()



commit ebc83efb1bf2e6c62abca85db516ee7eb04394fb
Author: Benjamin Otte <otte redhat com>
Date:   Sat Feb 19 20:45:54 2011 +0100

    dnd: Use G_N_ELEMENTS()
    
    Now that we have wesome macros in glib 2.0, we can use them. Woohoo, GTK
    2.0 will be so awesome in the future.
    (Did anybody touch dnd code this millenium?)

 gtk/gtkdnd.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 15128c8..8e4ffdd 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -305,8 +305,6 @@ static struct {
   { 0              ,  "dnd-none", dnd_cursor_none, NULL, NULL },
 };
 
-static const gint n_drag_cursors = sizeof (drag_cursors) / sizeof (drag_cursors[0]);
-
 /*********************
  * Utility functions *
  *********************/
@@ -731,7 +729,7 @@ gtk_drag_get_cursor (GdkDisplay        *display,
    */ 
   if (!info)
     {
-      for (i = 0 ; i < n_drag_cursors - 1; i++)
+      for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++)
 	if (drag_cursors[i].cursor != NULL)
 	  {
 	    g_object_unref (drag_cursors[i].cursor);
@@ -739,7 +737,7 @@ gtk_drag_get_cursor (GdkDisplay        *display,
 	  }
     }
  
-  for (i = 0 ; i < n_drag_cursors - 1; i++)
+  for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++)
     if (drag_cursors[i].action == action)
       break;
 
@@ -930,12 +928,12 @@ gtk_drag_update_cursor (GtkDragSourceInfo *info)
   if (!info->have_grab)
     return;
 
-  for (i = 0 ; i < n_drag_cursors - 1; i++)
+  for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++)
     if (info->cursor == drag_cursors[i].cursor ||
 	info->cursor == info->drag_cursors[i])
       break;
   
-  if (i == n_drag_cursors)
+  if (i == G_N_ELEMENTS (drag_cursors))
     return;
 
   cursor = gtk_drag_get_cursor (gdk_cursor_get_display (info->cursor), 
@@ -3879,7 +3877,7 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
 {
   gint i;
 
-  for (i = 0; i < n_drag_cursors; i++)
+  for (i = 0; i < G_N_ELEMENTS (drag_cursors); i++)
     {
       if (info->drag_cursors[i] != NULL)
         {



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