From 58166e645971a4812fef23702f45cacc8e64e419 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 24 Oct 2009 17:55:54 -0400 Subject: Prefer G_N_ELEMENTS over sizeof calculations. --- widgets/misc/test-calendar.c | 4 +--- widgets/table/e-table-click-to-add.c | 2 -- widgets/table/e-table-field-chooser-item.c | 4 +--- widgets/table/e-table-header-item.c | 5 ++--- 4 files changed, 4 insertions(+), 11 deletions(-) (limited to 'widgets') diff --git a/widgets/misc/test-calendar.c b/widgets/misc/test-calendar.c index 458d60f90a..83b8f11cd7 100644 --- a/widgets/misc/test-calendar.c +++ b/widgets/misc/test-calendar.c @@ -41,8 +41,6 @@ static GtkTargetEntry target_table[] = { { (gchar *) "E-SHORTCUT", 0, TARGET_SHORTCUT } }; -static guint n_targets = sizeof(target_table) / sizeof(target_table[0]); - static void on_date_range_changed (ECalendarItem *calitem); static void on_selection_changed (ECalendarItem *calitem); @@ -85,7 +83,7 @@ main (gint argc, gchar **argv) gtk_drag_dest_set (cal, GTK_DEST_DEFAULT_ALL, - target_table, n_targets, + target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); vbox = gtk_vbox_new (FALSE, 0); diff --git a/widgets/table/e-table-click-to-add.c b/widgets/table/e-table-click-to-add.c index 57769d1540..7cceadcec8 100644 --- a/widgets/table/e-table-click-to-add.c +++ b/widgets/table/e-table-click-to-add.c @@ -53,8 +53,6 @@ static guint etcta_signals [LAST_SIGNAL] = { 0 }; #define etcta_get_type e_table_click_to_add_get_type G_DEFINE_TYPE (ETableClickToAdd, etcta, GNOME_TYPE_CANVAS_GROUP) -#define ELEMENTS(x) (sizeof (x) / sizeof (x[0])) - enum { PROP_0, PROP_HEADER, diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c index 7f0f39a9f9..5cd2f9edc2 100644 --- a/widgets/table/e-table-field-chooser-item.c +++ b/widgets/table/e-table-field-chooser-item.c @@ -57,8 +57,6 @@ static guint etfci_signals [LAST_SIGNAL] = { 0, }; #define etfci_get_type e_table_field_chooser_item_get_type G_DEFINE_TYPE (ETableFieldChooserItem, etfci, GNOME_TYPE_CANVAS_ITEM) -#define ELEMENTS(x) (sizeof (x) / sizeof (x[0])) - static void etfci_drop_table_header (ETableFieldChooserItem *etfci); static void etfci_drop_full_header (ETableFieldChooserItem *etfci); @@ -547,7 +545,7 @@ etfci_start_drag (ETableFieldChooserItem *etfci, GdkEvent *event, double x, doub etfci_drag_types[0].target = g_strdup_printf("%s-%s", etfci_drag_types[0].target, etfci->dnd_code); d(g_print ("etfci - %s\n", etfci_drag_types[0].target)); - list = gtk_target_list_new (etfci_drag_types, ELEMENTS (etfci_drag_types)); + list = gtk_target_list_new (etfci_drag_types, G_N_ELEMENTS (etfci_drag_types)); context = gtk_drag_begin (widget, list, GDK_ACTION_MOVE, 1, event); g_free(etfci_drag_types[0].target); diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index 4bfa15f6ce..684c92037a 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -75,7 +75,6 @@ static guint ethi_signals [LAST_SIGNAL] = { 0, }; #define ethi_get_type e_table_header_item_get_type G_DEFINE_TYPE (ETableHeaderItem, ethi, GNOME_TYPE_CANVAS_ITEM) -#define ELEMENTS(x) (sizeof (x) / sizeof (x[0])) #define d(x) static void ethi_drop_table_header (ETableHeaderItem *ethi); @@ -881,7 +880,7 @@ ethi_realize (GnomeCanvasItem *item) */ ethi_drop_types[0].target = g_strdup_printf("%s-%s", ethi_drop_types[0].target, ethi->dnd_code); gtk_drag_dest_set (GTK_WIDGET (item->canvas), 0, - ethi_drop_types, ELEMENTS (ethi_drop_types), + ethi_drop_types, G_N_ELEMENTS (ethi_drop_types), GDK_ACTION_MOVE); g_free(ethi_drop_types[0].target); @@ -1169,7 +1168,7 @@ ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event) ethi_drag_types[0].target = g_strdup_printf( "%s-%s", ethi_drag_types[0].target, ethi->dnd_code); list = gtk_target_list_new ( - ethi_drag_types, ELEMENTS (ethi_drag_types)); + ethi_drag_types, G_N_ELEMENTS (ethi_drag_types)); context = gtk_drag_begin (widget, list, GDK_ACTION_MOVE, 1, event); g_free(ethi_drag_types[0].target); -- cgit v1.2.3