ok so lets say you have a square jxj matrix.
yes you would create these in a loop but you declare them outside the loop. Depending on the scope of what you are doing, you might not have to a declare a full array, e.g.:
gboolean toggle_cb(GtkToggleButton* widget, gpointer data)
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggle_cb), GINT_TO_POINTER((i*j)+k));
The signal connect passes both the widget itself as well as another parameter (I made use of the array indices in this case).