aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-10-25 05:55:54 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-10-27 21:25:01 +0800
commit58166e645971a4812fef23702f45cacc8e64e419 (patch)
treebedad70e39e2215a53105e0303c168e86140371a
parentc58b70659747967568a536e217b9440424709f92 (diff)
downloadgsoc2013-evolution-58166e645971a4812fef23702f45cacc8e64e419.tar.gz
gsoc2013-evolution-58166e645971a4812fef23702f45cacc8e64e419.tar.zst
gsoc2013-evolution-58166e645971a4812fef23702f45cacc8e64e419.zip
Prefer G_N_ELEMENTS over sizeof calculations.
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c3
-rw-r--r--addressbook/importers/evolution-ldif-importer.c3
-rw-r--r--calendar/gui/dialogs/recurrence-page.c6
-rw-r--r--calendar/gui/e-day-view-time-item.c3
-rw-r--r--calendar/gui/e-day-view.c13
-rw-r--r--e-util/e-error.c6
-rw-r--r--em-format/em-format-quote.c2
-rw-r--r--em-format/em-format.c4
-rw-r--r--filter/filter-datespec.c3
-rw-r--r--mail/e-searching-tokenizer.c2
-rw-r--r--mail/em-account-editor.c14
-rw-r--r--mail/em-folder-properties.c4
-rw-r--r--mail/em-format-html-display.c4
-rw-r--r--mail/em-vfolder-rule.c4
-rw-r--r--mail/message-list.c8
-rw-r--r--mail/message-tag-followup.c4
-rw-r--r--modules/mail/e-mail-shell-migrate.c2
-rw-r--r--modules/mail/em-mailer-prefs.c2
-rw-r--r--modules/mail/em-network-prefs.c2
-rw-r--r--plugins/prefer-plain/prefer-plain.c4
-rw-r--r--smime/lib/e-cert.c2
-rw-r--r--widgets/misc/test-calendar.c4
-rw-r--r--widgets/table/e-table-click-to-add.c2
-rw-r--r--widgets/table/e-table-field-chooser-item.c4
-rw-r--r--widgets/table/e-table-header-item.c5
25 files changed, 47 insertions, 63 deletions
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 5f16ac9a56..cca537d65e 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -74,7 +74,6 @@ static GtkTargetEntry drag_types[] = {
{ (gchar *) SOURCE_VCARD_LIST_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD_LIST },
{ (gchar *) VCARD_LIST_TYPE, 0, DND_TARGET_TYPE_VCARD_LIST }
};
-static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]);
static void
e_minicard_view_drag_data_get(GtkWidget *widget,
@@ -138,7 +137,7 @@ e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter, GdkEvent *event,
g_print ("dragging %d card(s)\n", g_list_length (view->drag_list));
- target_list = gtk_target_list_new (drag_types, num_drag_types);
+ target_list = gtk_target_list_new (drag_types, G_N_ELEMENTS (drag_types));
context = gtk_drag_begin (GTK_WIDGET (GNOME_CANVAS_ITEM (view)->canvas),
target_list, actions, 1/*XXX*/, event);
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index efc4a2bf71..1e6461a631 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -127,7 +127,6 @@ ldif_fields[] = {
{ "nsAIMid", E_CONTACT_IM_AIM, FLAG_LIST },
{ "mozilla_AimScreenName", E_CONTACT_IM_AIM, FLAG_LIST }
};
-static gint num_ldif_fields = sizeof(ldif_fields) / sizeof (ldif_fields[0]);
static GString *
getValue( gchar **src )
@@ -267,7 +266,7 @@ parseLine (LDIFImporter *gci, EContact *contact,
ldif_value = getValue(&value );
field_handled = FALSE;
- for (i = 0; i < num_ldif_fields; i ++) {
+ for (i = 0; i < G_N_ELEMENTS (ldif_fields); i ++) {
if (!g_ascii_strcasecmp (ptr, ldif_fields[i].ldif_attribute)) {
if (ldif_fields[i].flags & FLAG_WORK_ADDRESS) {
populate_contact_address (work_address, ptr, ldif_value->str);
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index a94fe9e37f..8b341f5bc8 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -1050,7 +1050,7 @@ make_recur_month_num_combo (gint month_index)
store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_INT);
/* Relation */
- for (i = 0; i < sizeof (options) / sizeof (options[0]); i++) {
+ for (i = 0; i < G_N_ELEMENTS (options); i++) {
gtk_tree_store_append (store, &iter, NULL);
gtk_tree_store_set (store, &iter, 0, _(options [i]), 1, month_num_options_map [i], -1);
}
@@ -1120,7 +1120,7 @@ make_recur_month_combobox (void)
combo = gtk_combo_box_new_text ();
- for (i = 0; i < sizeof (options) / sizeof (options[0]); i++) {
+ for (i = 0; i < G_N_ELEMENTS (options); i++) {
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(options[i]));
}
@@ -1635,7 +1635,7 @@ recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
/* Any funky shit? */
-#define N_HAS_BY(field) (count_by_xxx (field, sizeof (field) / sizeof (field[0])))
+#define N_HAS_BY(field) (count_by_xxx (field, G_N_ELEMENTS (field)))
n_by_second = N_HAS_BY (r->by_second);
n_by_minute = N_HAS_BY (r->by_minute);
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 5068ed47e0..ff0f6406a4 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -733,7 +733,6 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item,
{
static gint divisions[] = { 60, 30, 15, 10, 5 };
EDayView *day_view;
- gint num_divisions = sizeof (divisions) / sizeof (divisions[0]);
GtkWidget *menu, *item, *submenu;
gchar buffer[256];
GSList *group = NULL, *recent_zones, *s;
@@ -752,7 +751,7 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item,
menu, "selection-done",
G_CALLBACK (gtk_widget_destroy), NULL);
- for (i = 0; i < num_divisions; i++) {
+ for (i = 0; i < G_N_ELEMENTS (divisions); i++) {
g_snprintf (buffer, sizeof (buffer),
/* TO TRANSLATORS: %02i is the number of minutes; this is a context menu entry
* to change the length of the time division in the calendar day view, e.g.
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index af6fdc66e7..46a37ddc46 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -112,7 +112,6 @@ static GtkTargetEntry target_table[] = {
{ (gchar *) "text/x-calendar", 0, TARGET_VCALENDAR },
{ (gchar *) "text/calendar", 0, TARGET_VCALENDAR }
};
-static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
static void e_day_view_destroy (GtkObject *object);
static void e_day_view_realize (GtkWidget *widget);
@@ -1336,11 +1335,11 @@ e_day_view_init (EDayView *day_view)
/* Set up the drop sites. */
gtk_drag_dest_set (day_view->top_canvas,
GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
+ target_table, G_N_ELEMENTS (target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
gtk_drag_dest_set (day_view->main_canvas,
GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
+ target_table, G_N_ELEMENTS (target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
/* connect to ECalendarView's signals */
@@ -3927,8 +3926,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
day_view->resize_bars_event_num = -1;
}
- target_list = gtk_target_list_new (target_table,
- n_targets);
+ target_list = gtk_target_list_new (
+ target_table, G_N_ELEMENTS (target_table));
gtk_drag_begin (widget, target_list,
GDK_ACTION_COPY | GDK_ACTION_MOVE,
1, (GdkEvent*)mevent);
@@ -4030,8 +4029,8 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
day_view->resize_bars_event_num = -1;
}
- target_list = gtk_target_list_new (target_table,
- n_targets);
+ target_list = gtk_target_list_new (
+ target_table, G_N_ELEMENTS (target_table));
gtk_drag_begin (widget, target_list,
GDK_ACTION_COPY | GDK_ACTION_MOVE,
1, (GdkEvent*)mevent);
diff --git a/e-util/e-error.c b/e-util/e-error.c
index e31b7732d8..049e090fdc 100644
--- a/e-util/e-error.c
+++ b/e-util/e-error.c
@@ -102,7 +102,7 @@ map_response(const gchar *name)
{
gint i;
- for (i=0;i<sizeof(response_map)/sizeof(response_map[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (response_map); i++)
if (!strcmp(name, response_map[i].name))
return response_map[i].id;
@@ -125,7 +125,7 @@ map_type(const gchar *name)
gint i;
if (name) {
- for (i=0;i<sizeof(type_map)/sizeof(type_map[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (type_map); i++)
if (!strcmp(name, type_map[i].name))
return i;
}
@@ -320,7 +320,7 @@ ee_load_tables(void)
table = g_malloc0(sizeof(*table));
table->domain = "builtin";
table->errors = g_hash_table_new(g_str_hash, g_str_equal);
- for (i=0;i<sizeof(default_errors)/sizeof(default_errors[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (default_errors); i++)
g_hash_table_insert(table->errors, (gpointer) default_errors[i].id, &default_errors[i]);
g_hash_table_insert(error_table, (gpointer) table->domain, table);
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index c329769976..05fefa02e6 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -588,6 +588,6 @@ emfq_builtin_init(EMFormatQuoteClass *efhc)
{
gint i;
- for (i=0;i<sizeof(type_builtin_table)/sizeof(type_builtin_table[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (type_builtin_table); i++)
em_format_class_add_handler((EMFormatClass *)efhc, &type_builtin_table[i]);
}
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 3308763ee5..1285bcbf92 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -981,7 +981,7 @@ em_format_default_headers(EMFormat *emf)
gint i;
em_format_clear_headers(emf);
- for (i=0; i<sizeof(default_headers)/sizeof(default_headers[0]); i++)
+ for (i = 0; i < G_N_ELEMENTS (default_headers); i++)
em_format_add_header(emf, default_headers[i].name, default_headers[i].flags);
}
@@ -1988,7 +1988,7 @@ emf_builtin_init(EMFormatClass *class)
{
gint i;
- for (i=0;i<sizeof(type_builtin_table)/sizeof(type_builtin_table[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (type_builtin_table); i++)
g_hash_table_insert(class->type_handlers, type_builtin_table[i].mime_type, &type_builtin_table[i]);
}
diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c
index 5d1e573f9b..a0e981d111 100644
--- a/filter/filter-datespec.c
+++ b/filter/filter-datespec.c
@@ -91,7 +91,6 @@ static const timespan timespans[] = {
#undef ngettext
#define DAY_INDEX 3
-#define N_TIMESPANS (sizeof (timespans) / sizeof (timespans[0]))
struct _FilterDatespecPrivate {
GtkWidget *label_button;
@@ -264,7 +263,7 @@ get_best_span (time_t val)
{
gint i;
- for (i=N_TIMESPANS-1;i>=0;i--) {
+ for (i=G_N_ELEMENTS (timespans)-1;i>=0;i--) {
if (val % timespans[i].seconds == 0)
return i;
}
diff --git a/mail/e-searching-tokenizer.c b/mail/e-searching-tokenizer.c
index aac8a0a34f..4a3b6a9bac 100644
--- a/mail/e-searching-tokenizer.c
+++ b/mail/e-searching-tokenizer.c
@@ -122,7 +122,7 @@ ignore_tag (const gchar *tag)
}
*out = 0;
- for (i=0;i<sizeof(ignored_tags)/sizeof(ignored_tags[0]);i++) {
+ for (i = 0; i < G_N_ELEMENTS (ignored_tags); i++) {
if (strcmp (t, ignored_tags[i]) == 0)
return 1;
}
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 5b96a5f5b5..e46695e2d6 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -493,8 +493,6 @@ static struct {
{ N_("SSL encryption"), "always" }
};
-#define num_ssl_options (sizeof (ssl_options) / sizeof (ssl_options[0]))
-
static gboolean
is_email (const gchar *address)
{
@@ -689,7 +687,7 @@ em_account_editor_ssl_selector_new (gchar *widget_name, gchar *string1, gchar *s
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
- for (i=0;i<num_ssl_options;i++) {
+ for (i=0;i<G_N_ELEMENTS (ssl_options);i++) {
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _(ssl_options[i].label), 1, ssl_options[i].value, -1);
}
@@ -1586,7 +1584,7 @@ emae_service_provider_changed (EMAccountEditorService *service)
hide = CAMEL_PROVIDER_HIDDEN(service->provider, info->flag);
show = (enable && !hide)?gtk_widget_show:gtk_widget_hide;
- for (j=0; j < sizeof (info->widgets)/sizeof (info->widgets[0]); j++) {
+ for (j=0; j < G_N_ELEMENTS (info->widgets); j++) {
if (info->widgets[j] && (w = G_STRUCT_MEMBER(GtkWidget *, service, info->widgets[j]))) {
show (w);
if (j == 0) {
@@ -1777,7 +1775,7 @@ emae_refresh_providers (EMAccountEditor *emae, EMAccountEditorService *service)
tmp = camel_url_get_param (url, "use_ssl");
if (tmp == NULL)
tmp = "never";
- for (i=0;i<num_ssl_options;i++) {
+ for (i=0;i<G_N_ELEMENTS (ssl_options);i++) {
if (!strcmp (ssl_options[i].value, tmp)) {
gtk_combo_box_set_active (service->use_ssl, i);
break;
@@ -2018,7 +2016,7 @@ emae_setup_service (EMAccountEditor *emae, EMAccountEditorService *service, Glad
if (tmp == NULL)
tmp = "never";
- for (i=0;i<num_ssl_options;i++) {
+ for (i=0;i<G_N_ELEMENTS (ssl_options);i++) {
if (!strcmp (ssl_options[i].value, tmp)) {
gtk_combo_box_set_active (service->use_ssl, i);
break;
@@ -2152,7 +2150,7 @@ emae_queue_widgets (EMAccountEditor *emae, GladeXML *xml, const gchar *first, ..
}
va_end (ap);
- g_return_if_fail (i < sizeof (emae->priv->widgets)/sizeof (emae->priv->widgets[0]));
+ g_return_if_fail (i < G_N_ELEMENTS (emae->priv->widgets));
emae->priv->widgets[i] = NULL;
emae->priv->widgets_index = 0;
@@ -2181,7 +2179,7 @@ emae_identity_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget
g_free (gladefile);
/* Management & Identity fields, in the assistant the management frame is relocated to the last page later on */
- for (i=0;i<sizeof (emae_identity_entries)/sizeof (emae_identity_entries[0]);i++)
+ for (i=0;i<G_N_ELEMENTS (emae_identity_entries);i++)
gui->identity_entries[i] = emae_account_entry (emae, emae_identity_entries[i].name, emae_identity_entries[i].item, xml);
gui->management_frame = glade_xml_get_widget (xml, "management_frame");
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index a7236e66dd..7b7957149c 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -357,7 +357,7 @@ emfp_dialog_got_folder_quota (CamelFolder *folder,
|| !strcmp(prop_data->name, "Sent"))) {
emfp_items[EMFP_FOLDER_SECTION].label = _(prop_data->name);
if (!emfp_items_translated) {
- for (i=0;i<sizeof(emfp_items)/sizeof(emfp_items[0]);i++) {
+ for (i = 0; i < G_N_ELEMENTS (emfp_items); i++) {
if (emfp_items[i].label)
emfp_items[i].label = _(emfp_items[i].label);
}
@@ -415,7 +415,7 @@ emfp_dialog_got_folder_quota (CamelFolder *folder,
ec = em_config_new(E_CONFIG_BOOK, "org.gnome.evolution.mail.folderConfig");
prop_data->config = ec;
l = NULL;
- for (i=0;i<sizeof(emfp_items)/sizeof(emfp_items[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (emfp_items); i++)
l = g_slist_prepend(l, &emfp_items[i]);
e_config_add_items((EConfig *)ec, l, emfp_commit, NULL, emfp_free, prop_data);
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 46241186aa..6a2f56525c 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -731,7 +731,7 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc)
{
gint i;
- for (i=0;i<sizeof(type_builtin_table)/sizeof(type_builtin_table[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (type_builtin_table); i++)
em_format_class_add_handler((EMFormatClass *)efhc, &type_builtin_table[i]);
}
@@ -1036,7 +1036,7 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec
camel_strdown(simple_type);
drag_types[0].target = simple_type;
- gtk_drag_source_set(box, GDK_BUTTON1_MASK, drag_types, sizeof(drag_types)/sizeof(drag_types[0]), GDK_ACTION_COPY);
+ gtk_drag_source_set(box, GDK_BUTTON1_MASK, drag_types, G_N_ELEMENTS (drag_types), GDK_ACTION_COPY);
g_free(simple_type);
g_signal_connect(box, "drag-data-get", G_CALLBACK(efhd_drag_data_get), pobject);
diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c
index 2ccbe1378d..3a87c09751 100644
--- a/mail/em-vfolder-rule.c
+++ b/mail/em-vfolder-rule.c
@@ -258,7 +258,7 @@ xml_encode(FilterRule *fr)
node = FILTER_RULE_CLASS(parent_class)->xml_encode(fr);
g_return_val_if_fail (node != NULL, NULL);
- g_return_val_if_fail (vr->with < sizeof(with_names)/sizeof(with_names[0]), NULL);
+ g_return_val_if_fail (vr->with < G_N_ELEMENTS (with_names), NULL);
set = xmlNewNode(NULL, (const guchar *)"sources");
xmlAddChild(node, set);
@@ -279,7 +279,7 @@ set_with(EMVFolderRule *vr, const gchar *name)
{
gint i;
- for (i=0;i<sizeof(with_names)/sizeof(with_names[0]);i++) {
+ for (i = 0; i < G_N_ELEMENTS (with_names); i++) {
if (!strcmp(name, with_names[i])) {
vr->with = i;
return;
diff --git a/mail/message-list.c b/mail/message-list.c
index c45dbf3437..90c0812aff 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -2213,7 +2213,7 @@ ml_tree_drag_motion(ETree *tree, GdkDragContext *context, gint x, gint y, guint
gint i;
d(printf("atom drop '%s'\n", gdk_atom_name(targets->data)));
- for (i=0;i<sizeof(ml_drag_info)/sizeof(ml_drag_info[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (ml_drag_info); i++)
if (targets->data == (gpointer)ml_drag_info[i].atom)
actions |= ml_drag_info[i].actions;
}
@@ -2488,7 +2488,7 @@ message_list_class_init (MessageListClass *class)
GtkObjectClass *gtk_object_class;
gint i;
- for (i=0;i<sizeof(ml_drag_info)/sizeof(ml_drag_info[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (ml_drag_info); i++)
ml_drag_info[i].atom = gdk_atom_intern(ml_drag_info[i].target, FALSE);
g_type_class_add_private (class, sizeof (MessageListPrivate));
@@ -2640,14 +2640,14 @@ message_list_construct (MessageList *message_list)
G_CALLBACK (on_selection_changed_cmd), message_list);
e_tree_drag_source_set(message_list->tree, GDK_BUTTON1_MASK,
- ml_drag_types, sizeof(ml_drag_types)/sizeof(ml_drag_types[0]),
+ ml_drag_types, G_N_ELEMENTS (ml_drag_types),
GDK_ACTION_MOVE|GDK_ACTION_COPY);
g_signal_connect(message_list->tree, "tree_drag_data_get",
G_CALLBACK(ml_tree_drag_data_get), message_list);
e_tree_drag_dest_set(message_list->tree, GTK_DEST_DEFAULT_ALL,
- ml_drop_types, sizeof(ml_drop_types)/sizeof(ml_drop_types[0]),
+ ml_drop_types, G_N_ELEMENTS (ml_drop_types),
GDK_ACTION_MOVE|GDK_ACTION_COPY);
g_signal_connect(message_list->tree, "tree_drag_data_received",
diff --git a/mail/message-tag-followup.c b/mail/message-tag-followup.c
index 5141387b01..b9ae183f6b 100644
--- a/mail/message-tag-followup.c
+++ b/mail/message-tag-followup.c
@@ -64,8 +64,6 @@ static const gchar *available_flags[] = {
N_("Review"),
};
-static gint num_available_flags = sizeof (available_flags) / sizeof (available_flags[0]);
-
static MessageTagEditorClass *parent_class = NULL;
GType
@@ -307,7 +305,7 @@ construct (MessageTagEditor *editor)
followup->combo_entry = GTK_COMBO_BOX (glade_xml_get_widget (gui, "combo"));
gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (followup->combo_entry)));
- for (i = 0; i < num_available_flags; i++)
+ for (i = 0; i < G_N_ELEMENTS (available_flags); i++)
gtk_combo_box_append_text (followup->combo_entry, (gchar *) _(available_flags[i]));
gtk_combo_box_set_active (followup->combo_entry, DEFAULT_FLAG);
diff --git a/modules/mail/e-mail-shell-migrate.c b/modules/mail/e-mail-shell-migrate.c
index 967f80053f..43cd1a5185 100644
--- a/modules/mail/e-mail-shell-migrate.c
+++ b/modules/mail/e-mail-shell-migrate.c
@@ -1670,7 +1670,7 @@ em_migrate_folder(EMMigrateSession *session, const gchar *dirname, const gchar *
}
/* copy over the metadata files */
- for (i = 0; i < sizeof(meta_ext)/sizeof(meta_ext[0]); i++) {
+ for (i = 0; i < G_N_ELEMENTS (meta_ext); i++) {
g_string_truncate (src, slen);
g_string_truncate (dest, dlen);
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index 630f77563f..03f8973ab4 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -845,7 +845,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
*/
ec = em_config_new(E_CONFIG_BOOK, "org.gnome.evolution.mail.prefs");
l = NULL;
- for (i=0;i<sizeof(emmp_items)/sizeof(emmp_items[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (emmp_items); i++)
l = g_slist_prepend(l, &emmp_items[i]);
e_config_add_items((EConfig *)ec, l, NULL, NULL, emmp_free, prefs);
diff --git a/modules/mail/em-network-prefs.c b/modules/mail/em-network-prefs.c
index f2d21545bd..5c6c511b72 100644
--- a/modules/mail/em-network-prefs.c
+++ b/modules/mail/em-network-prefs.c
@@ -323,7 +323,7 @@ em_network_prefs_construct (EMNetworkPrefs *prefs)
*/
ec = em_config_new(E_CONFIG_BOOK, "org.gnome.evolution.mail.networkPrefs");
l = NULL;
- for (i=0;i<sizeof(emnp_items)/sizeof(emnp_items[0]);i++)
+ for (i = 0; i < G_N_ELEMENTS (emnp_items); i++)
l = g_slist_prepend(l, &emnp_items[i]);
e_config_add_items((EConfig *)ec, l, NULL, NULL, emnp_free, prefs);
diff --git a/plugins/prefer-plain/prefer-plain.c b/plugins/prefer-plain/prefer-plain.c
index 39e8d66b58..58d3425ffe 100644
--- a/plugins/prefer-plain/prefer-plain.c
+++ b/plugins/prefer-plain/prefer-plain.c
@@ -239,7 +239,7 @@ org_gnome_prefer_plain_config_mode(struct _EPlugin *epl, struct _EConfigHookItem
dropdown = (GtkComboBox *)gtk_combo_box_new();
cell = gtk_cell_renderer_text_new();
store = gtk_list_store_new(1, G_TYPE_STRING);
- for (i=0;i<sizeof(epp_options)/sizeof(epp_options[0]);i++) {
+ for (i = 0; i < G_N_ELEMENTS (epp_options); i++) {
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, _(epp_options[i].label), -1);
}
@@ -289,7 +289,7 @@ e_plugin_lib_enable(EPlugin *ep, gint enable)
epp_gconf = gconf_client_get_default();
key = gconf_client_get_string(epp_gconf, "/apps/evolution/eplugin/prefer_plain/mode", NULL);
if (key) {
- for (i=0;i<sizeof(epp_options)/sizeof(epp_options[0]);i++) {
+ for (i = 0; i < G_N_ELEMENTS (epp_options); i++) {
if (!strcmp(epp_options[i].key, key)) {
epp_mode = i;
break;
diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c
index 02b6ccdb3b..2591678cec 100644
--- a/smime/lib/e-cert.c
+++ b/smime/lib/e-cert.c
@@ -416,7 +416,7 @@ e_cert_get_usage(ECert *cert)
GString *str = g_string_new("");
CERTCertificate *icert = e_cert_get_internal_cert (cert);
- for (i=0;i<sizeof(usageinfo)/sizeof(usageinfo[0]);i++) {
+ for (i = 0; i < G_N_ELEMENTS (usageinfo); i++) {
if (icert->keyUsage & usageinfo[i].bit) {
if (str->len != 0)
g_string_append(str, ", ");
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);